///*
//package com.example.securitydemo.config;
//
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.security.config.annotation.web.builders.HttpSecurity;
//import org.springframework.security.core.userdetails.User;
//import org.springframework.security.core.userdetails.UserDetails;
//import org.springframework.security.core.userdetails.UserDetailsService;
//import org.springframework.security.provisioning.InMemoryUserDetailsManager;
//import org.springframework.security.web.DefaultSecurityFilterChain;
//import org.springframework.security.web.SecurityFilterChain;
//
//import javax.annotation.Resource;
//
//@Configuration
//public class MyConfig {
//
//
//
//    @Bean
//    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
////        http.authorizeHttpRequests((authz) -> authz
////                        .anyRequest().authenticated());
////
////
////                http.formLogin().loginPage("");
//        http.formLogin().loginPage("/index.html")// 自定义的登录的页面
//                .loginProcessingUrl("/usrlogin") //
//                .usernameParameter("myname")// index.html  /login
//                .passwordParameter("mypwd")
//                .defaultSuccessUrl("/success.html") // 默认的成功之后的页面
//                .failureUrl("/error.html").permitAll()
//                .and().authorizeRequests().antMatchers("/","/index.html","/login").permitAll() // 、login不需要拦截
//                // 有 user的角色  /test    user
//                //.and().authorizeRequests().antMatchers("/test").hasRole("user")//hasAuthority("user")
//                .and().exceptionHandling().accessDeniedPage("/403.html")
//                .and().authorizeRequests().anyRequest().authenticated() // 需要认证
//                .and().logout().logoutUrl("/logOut").logoutSuccessUrl("/index.html").permitAll()
//                .and().csrf().disable();
//        DefaultSecurityFilterChain build = http.build();
//
//        return build;
//    }
//
//    // bean
////    @Bean //
////    public UserDetailsService users() {
////        User.UserBuilder users = User.withDefaultPasswordEncoder();
////        UserDetails user = users
////                .username("yyl")
////                .password("123")
////                .roles("USER")
////                .build();
////
////        return new InMemoryUserDetailsManager(user);
////    }
//}*/
